#!/bin/bash

file_server="file_server"
read_server="read_server"
main_server="main_server"

function check_process {
    local process_name=$1
    local process_status=$(ps aux | grep -v grep | grep "$process_name")
    local process_pid=$(pgrep "$process_name")

    if [ -n "$process_status" ]; then
        echo "$process_name is running. $process_name pid is $process_pid"
        return 0  # Process is running
    else
        echo "$process_name is not running."
        return 1  # Process is not running
    fi
}

while true; do
    check_process $file_server
    check_process $read_server
    check_process $main_server

    sleep 5
done
